﻿<link href="~/Content/ViewStyle/LeftMenu.css" rel="stylesheet" type="text/css" />
<link href="~/Content/bootstrap/bootstrap-treeview.min.css" rel="stylesheet" />
<script src="~/Scripts/bootstrap-treeview.min.js"></script>

<div id="myTree" class="fullHeight scrollYAuto"></div>
<script src="~/Scripts/ViewScript/LeftMenuTree.js" type="text/javascript"></script>
@*@functions{
    System.Text.StringBuilder BuildMenu(string path, bool isTop, System.Text.StringBuilder sb)
    {
        if (sb == null)
            sb = new System.Text.StringBuilder();
        bool isFirst = true;
        foreach (var file in System.IO.Directory.GetFiles(path))
        {
            if (isTop && isFirst)
            {
                sb.Append("<li class=\"active width100\">");
                isFirst = false;
            }
            else
            {
                sb.Append("<li class=\"width100\">");
            }
            var fileName = System.IO.Path.GetFileNameWithoutExtension(file);
            var filePath = file.Replace(SpreadSheetViewer.Helper.DirectoryManagmentUtils.CurrentDataDirectory, "").Replace("\\", "\\\\");
            sb.Append("<button class=\"btn btn-default openFile width100\" onclick=\"openFile('" + filePath + "')\">" + fileName + "</button></li>");
        }
        foreach (var dic in System.IO.Directory.GetDirectories(path))
        {
            string fileName = dic.Replace(path, "").Replace("/", "").Replace("\\", "");
            if (isTop)
            {
                sb.Append("<li class=\"dropdown width100\"><a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">" + fileName + "<b class=\"caret\"></b></a><ul class=\"dropdown-menu menu-top\">");
                BuildMenu(dic, false, sb);
                sb.Append("</ul></li>");
            }
            else
            {
                sb.Append("<li class=\"dropdown-submenu width100\"><a href=\"#\" tabindex=\"-1\">" + fileName + "</a><ul class=\"dropdown-menu\">");
                BuildMenu(dic, false, sb);
                sb.Append("</ul></li>");
            }
        }
        return sb;
    }
}

<nav class="navbar navbar-default" role="navigation">
    <div>
        <ul class="nav navbar-nav">
            @Html.Raw(BuildMenu(SpreadSheetViewer.Helper.DirectoryManagmentUtils.CurrentDataDirectory, true, null).ToString())
        </ul>
    </div>
</nav>*@
